package com.kx.file.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * 文件上传的配置信息
 * @Author Sun
 * @Date 2021/7/22 20:33
 */
@Configuration
public class MultipartConfig {

    @Bean
    public MultipartConfigElement multipartConfigElement(){
        MultipartConfigFactory factory=new MultipartConfigFactory();
        //限制大小为200M
        DataSize dataSize=DataSize.ofBytes(200*1024*1024);
        factory.setMaxRequestSize(dataSize);
        factory.setMaxFileSize(dataSize);
        return factory.createMultipartConfig();
    }
}
